package com.cynteka.cyfoman.core.config;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;

@XmlRootElement
public class ActionMD {

    private String name;

    private List<ParamMD> actionParams = new ArrayList<ParamMD>();

    private List<String> folders = new ArrayList<String>();

    private String table;

    private boolean fileAction = false;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ActionMD actionMD = (ActionMD) o;

        if (fileAction != actionMD.fileAction) return false;
        if (actionParams != null ? !actionParams.equals(actionMD.actionParams) : actionMD.actionParams != null)
            return false;
        if (folders != null ? !folders.equals(actionMD.folders) : actionMD.folders != null) return false;
        if (name != null ? !name.equals(actionMD.name) : actionMD.name != null) return false;
        return !(table != null ? !table.equals(actionMD.table) : actionMD.table != null);

    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (actionParams != null ? actionParams.hashCode() : 0);
        result = 31 * result + (folders != null ? folders.hashCode() : 0);
        result = 31 * result + (table != null ? table.hashCode() : 0);
        result = 31 * result + (fileAction ? 1 : 0);
        return result;
    }

    @XmlElement
    public boolean isFileAction() {
        return fileAction;
    }

    public void setFileAction(boolean fileAction) {
        this.fileAction = fileAction;
    }

    public ActionMD() {

    }

    public ActionMD(String name) {
        this.name = name;
    }

    @XmlElement
    public String getTable() {
        return table;
    }

    public void setTable(String table) {
        this.table = table;
    }

    @XmlElement
    public List<String> getFolders() {
        return folders;
    }

    public void setFolders(List<String> folders) {
        this.folders = folders;
    }

    @XmlElement
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlElement
    public List<ParamMD> getActionParams() {
        return actionParams;
    }

    public void setActionParams(List<ParamMD> actionParams) {
        this.actionParams = actionParams;
    }

    @Override
    public String toString() {
        //noinspection HardCodedStringLiteral
        return "ActionMD{" +
                "name='" + name + '\'' +
                ", actionParams=" + actionParams +
                ", folders=" + folders +
                ", table='" + table + '\'' +
                ", fileAction=" + fileAction +
                '}';
    }
}
